package com.baosight.sczx.zm.ca.service;

import java.util.HashMap;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.Utils;
import com.baosight.sczx.common.zm.cInterface.Department;
import com.baosight.sczx.common.zm.cInterface.cs.Engineering;
import com.baosight.sczx.zm.ca.domain.ZMCA20;

public class ServiceZMCA20  extends ServiceEPBase{

	/**
	 * 页面初始化，返回组织好的层级小代码
	 * 
	 * @param EiInfo
	 * @return EiInfo
	 */
	public EiInfo initLoad(EiInfo inInfo) {
		
		EiInfo outInfo = new EiInfo();
		
		outInfo.addBlock(this.getEngineeringType());
		outInfo.addBlock(this.getDrillEngineeringType());
		outInfo.addBlock(Department.getInstance().getConstructionUnit("cmes.ca.department", "orgCode", "orgName", false));		
		outInfo.addBlock(Engineering.getEngineeringDetail("cmes.ca.engineering", null, null,null, false));
		
		return outInfo;				
		
		//return this.query(inInfo);
	}	
	
	public EiInfo queryProjectOrg(EiInfo inInfo) {
		EiInfo outInfo = new EiInfo();
		
//		inInfo.setMethodParam(MethodParamConstants.sqlName,"ZMCA20.queryOrg");
//	    inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCA20());		
//		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
//		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "org");	
		
		//outInfo.addBlock(super.query(inInfo, true).getBlock("org"));
		outInfo.addBlock(Utils.generateOutBlock("org", new ZMCA20(), inInfo, "ZMCA20.queryOrg", false, "queryBlock"));
		return outInfo;
	}
	
	public EiInfo queryProjectName(EiInfo inInfo) {
		EiInfo outInfo = new EiInfo();
		
//		inInfo.setMethodParam(MethodParamConstants.sqlName,"ZMCA20.queryPrj");
//	    inInfo.setMethodParam(MethodParamConstants.daoEPBaseBean, new ZMCA20());		
//		inInfo.setMethodParam(MethodParamConstants.queryBlock,"queryBlock");
//		inInfo.setMethodParam(MethodParamConstants.outDataBlock, "eng");	
//		outInfo.addBlock(super.query(inInfo, true).getBlock("eng"));
		outInfo.addBlock(Utils.generateOutBlock("eng", new ZMCA20(), inInfo, "ZMCA20.queryPrj", false, "queryBlock"));
		return outInfo;
	}
	
	
	
	/**
	 * 获取工程类型
	 * <p>Function: getPlanType</p>
	 * <p>Description: </p>
	 * <p>return value:EiBlock</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-07-11 12:19:00 王琪
	 * </p>
	 *
	 */		
	public EiBlock getDrillEngineeringType(){
		EiBlock block = new EiBlock("cmes.ca.drillrelatetype");
		
		EiColumn eiColumn = new EiColumn("display");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("value");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		 
		Map<String, String> map = new HashMap<String, String>();
		map.put("display", "采煤工程");
		map.put("value", "0");
		block.addRow(map);
         
		map = new HashMap<String, String>();
		map.put("display", "掘进工程");
		map.put("value", "1");
		block.addRow(map);
         

		
		map = new HashMap<String, String>();
		map.put("display", "开拓工程");
		map.put("value", "3");
		block.addRow(map);			

//		map = new HashMap<String, String>();
//		map.put("display", "钻孔工程");
//		map.put("value", "2");
//		block.addRow(map);	
		
		return block;
	}
	
	/**
	 * 
	 * <p>Function: getEngineeringType</p>
	 * <p>Description: </p>
	 * <p>return value:EiBlock</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-9-6上午09:44:02 严洪浩
	 * </p>
	 *
	 */
	public EiBlock getEngineeringType(){
		EiBlock block = new EiBlock("cmes.ca.engineeringtype");
		
		EiColumn eiColumn = new EiColumn("display");
		eiColumn.setType("C");
		block.addMeta(eiColumn);

		eiColumn = new EiColumn("value");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
         
		Map<String, String> map = new HashMap<String, String>();
		map.put("display", "采煤工程");
		map.put("value", "0");
		block.addRow(map);
		 
		map = new HashMap<String, String>();
		map.put("display", "掘进工程");
		map.put("value", "1");
		block.addRow(map);
		 
		map = new HashMap<String, String>();
		map.put("display", "防突打钻");
		map.put("value", "2");
		block.addRow(map);
		 
		map = new HashMap<String, String>();
		map.put("display", "其他工程");
		map.put("value", "3");
		block.addRow(map);
		
		return block;
	}
		
}
